import Category from './cateEnum'
// 默认public属性
class DataItem {
    id!:number; // !初始化  可以为空
    categoryId: Category;
    title!: string;
    content!: string;
    createTime!: string
    constructor(id: number = -1, categoryId:Category=-1,title:string='',content:string='', createTime:string='') {
        this.id = id
        this.categoryId = categoryId
        this.title = title
        this.content = content
        this.createTime = this.dataFormat()
    }

    dataFormat (): string {
        let nowDate = new Date()
        const date = {
            year: nowDate.getFullYear(),
            month: nowDate.getMonth() + 1,
            date: nowDate.getDate(),
        }
        const newmonth = date.month>10?date.month:'0'+date.month
        const day = date.date>10?date.date:'0'+date.date
        let systemDate = date.year + '-' + newmonth + '-' + day
        return   systemDate
    }


}

export default DataItem